<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Pseudo-Types</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.1.2 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Data Types"
HREF="datatype.html"><LINK
REL="PREVIOUS"
TITLE="Object Identifier Types"
HREF="datatype-oid.html"><LINK
REL="NEXT"
TITLE="Functions and Operators"
HREF="functions.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2011-12-01T22:07:59"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.1.2 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="Object Identifier Types"
HREF="datatype-oid.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="datatype.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 8. Data Types</TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="Functions and Operators"
HREF="functions.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="DATATYPE-PSEUDO"
>8.17. Pseudo-Types</A
></H1
><P
>    The <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> type system contains a
    number of special-purpose entries that are collectively called
    <I
CLASS="FIRSTTERM"
>pseudo-types</I
>.  A pseudo-type cannot be used as a
    column data type, but it can be used to declare a function's
    argument or result type.  Each of the available pseudo-types is
    useful in situations where a function's behavior does not
    correspond to simply taking or returning a value of a specific
    <ACRONYM
CLASS="ACRONYM"
>SQL</ACRONYM
> data type.  <A
HREF="datatype-pseudo.html#DATATYPE-PSEUDOTYPES-TABLE"
>Table 8-24</A
> lists the existing
    pseudo-types.
   </P
><DIV
CLASS="TABLE"
><A
NAME="DATATYPE-PSEUDOTYPES-TABLE"
></A
><P
><B
>Table 8-24. Pseudo-Types</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
><TT
CLASS="TYPE"
>any</TT
></TD
><TD
>Indicates that a function accepts any input data type.</TD
></TR
><TR
><TD
><TT
CLASS="TYPE"
>anyarray</TT
></TD
><TD
>Indicates that a function accepts any array data type
        (see <A
HREF="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC"
>Section 35.2.5</A
>).</TD
></TR
><TR
><TD
><TT
CLASS="TYPE"
>anyelement</TT
></TD
><TD
>Indicates that a function accepts any data type
        (see <A
HREF="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC"
>Section 35.2.5</A
>).</TD
></TR
><TR
><TD
><TT
CLASS="TYPE"
>anyenum</TT
></TD
><TD
>Indicates that a function accepts any enum data type
        (see <A
HREF="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC"
>Section 35.2.5</A
> and
        <A
HREF="datatype-enum.html"
>Section 8.7</A
>).</TD
></TR
><TR
><TD
><TT
CLASS="TYPE"
>anynonarray</TT
></TD
><TD
>Indicates that a function accepts any non-array data type
        (see <A
HREF="extend-type-system.html#EXTEND-TYPES-POLYMORPHIC"
>Section 35.2.5</A
>).</TD
></TR
><TR
><TD
><TT
CLASS="TYPE"
>cstring</TT
></TD
><TD
>Indicates that a function accepts or returns a null-terminated C string.</TD
></TR
><TR
><TD
><TT
CLASS="TYPE"
>internal</TT
></TD
><TD
>Indicates that a function accepts or returns a server-internal
        data type.</TD
></TR
><TR
><TD
><TT
CLASS="TYPE"
>language_handler</TT
></TD
><TD
>A procedural language call handler is declared to return <TT
CLASS="TYPE"
>language_handler</TT
>.</TD
></TR
><TR
><TD
><TT
CLASS="TYPE"
>fdw_handler</TT
></TD
><TD
>A foreign-data wrapper handler is declared to return <TT
CLASS="TYPE"
>fdw_handler</TT
>.</TD
></TR
><TR
><TD
><TT
CLASS="TYPE"
>record</TT
></TD
><TD
>Identifies a function returning an unspecified row type.</TD
></TR
><TR
><TD
><TT
CLASS="TYPE"
>trigger</TT
></TD
><TD
>A trigger function is declared to return <TT
CLASS="TYPE"
>trigger.</TT
></TD
></TR
><TR
><TD
><TT
CLASS="TYPE"
>void</TT
></TD
><TD
>Indicates that a function returns no value.</TD
></TR
><TR
><TD
><TT
CLASS="TYPE"
>opaque</TT
></TD
><TD
>An obsolete type name that formerly served all the above purposes.</TD
></TR
></TBODY
></TABLE
></DIV
><P
>    Functions coded in C (whether built-in or dynamically loaded) can be
    declared to accept or return any of these pseudo data types.  It is up to
    the function author to ensure that the function will behave safely
    when a pseudo-type is used as an argument type.
   </P
><P
>    Functions coded in procedural languages can use pseudo-types only as
    allowed by their implementation languages.  At present the procedural
    languages all forbid use of a pseudo-type as argument type, and allow
    only <TT
CLASS="TYPE"
>void</TT
> and <TT
CLASS="TYPE"
>record</TT
> as a result type (plus
    <TT
CLASS="TYPE"
>trigger</TT
> when the function is used as a trigger).  Some also
    support polymorphic functions using the types <TT
CLASS="TYPE"
>anyarray</TT
>,
    <TT
CLASS="TYPE"
>anyelement</TT
>, <TT
CLASS="TYPE"
>anyenum</TT
>, and <TT
CLASS="TYPE"
>anynonarray</TT
>.
   </P
><P
>    The <TT
CLASS="TYPE"
>internal</TT
> pseudo-type is used to declare functions
    that are meant only to be called internally by the database
    system, and not by direct invocation in an <ACRONYM
CLASS="ACRONYM"
>SQL</ACRONYM
>
    query.  If a function has at least one <TT
CLASS="TYPE"
>internal</TT
>-type
    argument then it cannot be called from <ACRONYM
CLASS="ACRONYM"
>SQL</ACRONYM
>.  To
    preserve the type safety of this restriction it is important to
    follow this coding rule: do not create any function that is
    declared to return <TT
CLASS="TYPE"
>internal</TT
> unless it has at least one
    <TT
CLASS="TYPE"
>internal</TT
> argument.
   </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="datatype-oid.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="functions.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Object Identifier Types</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="datatype.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Functions and Operators</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>